import os
import json
import pandas as pd

if not os.path.exists("../prepare_data/gpt-3.5-turbo/alpaca_json.json"):
    data_df = pd.read_parquet("../prepare_data/gpt-3.5-turbo/train-00000-of-00001-a09b74b3ef9c3b56.parquet")
    data_df['text'] = data_df['text'].apply(lambda v: json.dumps({"text": v}))
    with open("../prepare_data/gpt-3.5-turbo/alpaca_json.json", encoding='utf-8', mode='w') as f:
        for i, row in data_df.iterrows():
            f.write(row['text'])
            f.write('\n')
